package com.ttwl.www.app;

import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.ttwl.www.app.homepage.FreeActivity;

public class HomeFragment extends Fragment {


    private Button mJumpFree,mJumpVip,mJumpLive;
    private View view;
    private RecyclerView mHotvideo;


    public HomeFragment() {

    }

    public static Fragment newInstance() {
        HomeFragment fragment = new HomeFragment();
        return fragment;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_home, container, false);
    }


    //  点击后跳转到免费专区界面
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mJumpFree = (Button) view.findViewById(R.id.jump_free);
        mJumpVip  = (Button) view.findViewById(R.id.jump_vip);
        mJumpLive = (Button) view.findViewById(R.id.jump_live);

        setListeners();
    }






    private Context getApplicationContext() {
        return null;
    }

    private void setListeners() {
        OnClick onClick = new OnClick();
        mJumpFree.setOnClickListener(onClick);
        mJumpVip.setOnClickListener(onClick);
        mJumpLive.setOnClickListener(onClick);
    }



    private class OnClick implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            Intent intent = null;
            switch (v.getId()) {
                case R.id.jump_free:
                    //跳转到免费专区界面--free
                    intent = new Intent(getActivity(),FreeActivity.class);
                    break;

//                case R.id.jump_vip:
//                    //跳转到免费专区界面--free
//                    intent = new Intent(getActivity(), LiveActivity.class);
//                    break;


            }
            startActivity(intent);
        }
    }

}